﻿using J.Model;
using J.ProductGet.Application.Command.AggregateCommand;
using MediatR;
using SqlSugar;

namespace J.ProductGet.Application.CommandHandler.AggregateCommandHandler
{
    public class AggregateBackilCommandHandler : IRequestHandler<AggregateBackilCommand, List<AggregateCommodity>>
    {
        private readonly ISqlSugarClient _sqlSugarClient;
        public AggregateBackilCommandHandler(ISqlSugarClient sqlSugarClient)
        {
            _sqlSugarClient = sqlSugarClient;
        }
        public async Task<List<AggregateCommodity>> Handle(AggregateBackilCommand request, CancellationToken cancellationToken)
        {
            return await _sqlSugarClient.Queryable<AggregateCommodity>().Where(s => s.AggregateID == request.AggregateID).ToListAsync();
        }
    }
}
